/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2019 All Rights Reserved.
 */
package com.suxiaoxiao.springbootlearn.designpattern.strategypattern;

import com.suxiaoxiao.springbootlearn.designpattern.strategypattern.behavior.FlyBehavior;
import com.suxiaoxiao.springbootlearn.designpattern.strategypattern.behavior.QuackBehavior;

/**
 * 鸭子类
 * 父类
 *
 * @author zhaorongzhang
 * @version Duck.java, v 0.1 2019/12/28 2:51 下午 zhaorongzhang Exp $$
 */
public abstract class Duck {

    protected FlyBehavior flyBehavior;
    protected QuackBehavior quackBehavior;

    /**
     * 说明
     */
    public abstract void display();

    public void performQuack() {
        quackBehavior.quack();
    }

    public void performFly() {
        flyBehavior.fly();
    }

    public void swim() {
        System.out.println("All ducks float, even decoys!");
    }

    /**
     * 改变飞的行为
     * @param flyBehavior
     */
    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    /**
     * 改变叫的行为
     * @param quackBehavior
     */
    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

}